import { ActiveBaseIcon } from "../activity/icon/ActiveBaseIcon";
import { LayerManager } from "../../manager/LayerManager";
import { SecTimerView } from "../common/SecTimerView";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { EventName } from "../../mvc/EventName";
import { ObjCreate } from "../common/ObjCreate";
import { EffectManager } from "../../manager/EffectManager";
import { DataEvent } from "../../events/DataEvent";
import { ResFileConst } from "../../resource/ResFileConst";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
type int = number;
//class LadderBattlefieldIcon
    
    export  class LadderBattlefieldIcon extends ActiveBaseIcon
    {
        constructor(arg1: string=null)
        {
            super(arg1);
            this.layer = LayerManager.rightTopUILayer;
            this.createChildren();
            this.addListeners();
            return;
        }

        public addTfLeftTime(arg1: int): void
        {
            if (arg1 > 0) 
            {
                if (!this._tfLeftTime) 
                {
                    this._tfLeftTime = new SecTimerView();
                }
                this._tfLeftTime.mouseEnabled = false;
                this._tfLeftTime.defaultTextFormat = GlobalStyle.setTextFormatAlign(GlobalStyle._textFormat5, flash.text.TextFormatAlign.CENTER);
                this._tfLeftTime.filters = [FilterConst.glowFilter];
                this._tfLeftTime.configEventListener(EventName.SecViewTimeChange, this.onSecViewTimeChange);
                ObjCreate.setObjAttri(this._tfLeftTime, 0, 50, 60, 20, this);
                this._tfLeftTime.setLeftTime(arg1);
            }
            return;
        }

        /* internal  */removeLightMask(): void
        {
            if (this._lightMask) 
            {
                EffectManager.disposeLightMask(this._lightMask);
                this._lightMask = null;
            }
            return;
        }

        /* internal  */onSecViewTimeChange(arg1: DataEvent): void
        {
            if (int(arg1.data) <= 0) 
            {
                this._tfLeftTime.stop();
                this._tfLeftTime.dispose();
            }
            return;
        }

        /* internal  */createChildren(): void
        {
            this._lightMask = EffectManager.getLightMask(75, 64);
            ObjCreate.setObjAttri(this._lightMask, -3, -3, -1, -1, this);
            this._btn = ObjCreate.createGLoadedButton(ResFileConst.LadderBattlefieldBtn, 0, 0, 60, 50, this);
            return;
        }

        /* internal  */addListeners(): void
        {
            this._btn.addEventListener(flash.events.MouseEvent.CLICK, this.onClickBtn);
            return;
        }

        /* internal  */onClickBtn(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.removeLightMask();
            Dispatcher.dispatchEvent(new DataEvent(EventName.LadderBattlefieldIconClick));
            return;
        }

        /* internal */ /* var */_btn: GLoadedButton;

        /* internal */ /* var */_lightMask: LightMask;

        /* internal */ /* var */_tfLeftTime: SecTimerView;
    }
